package com.ruoyi.ctcx.service.impl;

import java.math.BigDecimal;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.ctcx.domain.TbInsuranceMain;
import com.ruoyi.ctcx.domain.TbInsuranceSettleCase;
import com.ruoyi.ctcx.domain.ro.InsuranceParam;
import com.ruoyi.ctcx.domain.ro.InsuranceQueryParam;
import com.ruoyi.ctcx.domain.vo.TbInsuranceSettleDetailVo;
import com.ruoyi.ctcx.domain.vo.TbInsuranceSettleQueryVo;
import com.ruoyi.ctcx.service.ITbInsuranceSettleCaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.ctcx.mapper.TbInsuranceSettleMapper;
import com.ruoyi.ctcx.domain.TbInsuranceSettle;
import com.ruoyi.ctcx.service.ITbInsuranceSettleService;

/**
 * 保险理赔信息Service业务层处理
 * 
 * @author lss
 * @date 2024-11-19
 */
@Service
public class TbInsuranceSettleServiceImpl implements ITbInsuranceSettleService 
{
    @Autowired
    private TbInsuranceSettleMapper tbInsuranceSettleMapper;


    @Autowired
    private ITbInsuranceSettleCaseService tbInsuranceSettleCaseService;

    /**
     * 查询保险理赔信息
     * 
     * @param id 保险理赔信息主键
     * @return 保险理赔信息
     */
    @Override
    public TbInsuranceSettle selectTbInsuranceSettleById(String id)
    {
        return tbInsuranceSettleMapper.selectTbInsuranceSettleById(id);
    }

    /**
     * 查询保险理赔信息列表
     * 
     * @param tbInsuranceSettle 保险理赔信息
     * @return 保险理赔信息
     */
    @Override
    public List<TbInsuranceSettle> selectTbInsuranceSettleList(TbInsuranceSettle tbInsuranceSettle)
    {
        return tbInsuranceSettleMapper.selectTbInsuranceSettleList(tbInsuranceSettle);
    }

    /**
     * 新增保险理赔信息
     * 
     * @param tbInsuranceSettle 保险理赔信息
     * @return 结果
     */
    @Override
    public int insertTbInsuranceSettle(TbInsuranceSettle tbInsuranceSettle)
    {
        tbInsuranceSettle.setCreateTime(DateUtils.getNowDate());
        return tbInsuranceSettleMapper.insertTbInsuranceSettle(tbInsuranceSettle);
    }

    /**
     * 修改保险理赔信息
     * 
     * @param tbInsuranceSettle 保险理赔信息
     * @return 结果
     */
    @Override
    public int updateTbInsuranceSettle(TbInsuranceSettle tbInsuranceSettle)
    {
        tbInsuranceSettle.setUpdateTime(DateUtils.getNowDate());
        return tbInsuranceSettleMapper.updateTbInsuranceSettle(tbInsuranceSettle);
    }

    /**
     * 批量删除保险理赔信息
     * 
     * @param ids 需要删除的保险理赔信息主键
     * @return 结果
     */
    @Override
    public int deleteTbInsuranceSettleByIds(String[] ids)
    {
        return tbInsuranceSettleMapper.deleteTbInsuranceSettleByIds(ids);
    }

    /**
     * 删除保险理赔信息信息
     * 
     * @param id 保险理赔信息主键
     * @return 结果
     */
    @Override
    public int deleteTbInsuranceSettleById(String id)
    {
        return tbInsuranceSettleMapper.deleteTbInsuranceSettleById(id);
    }

    @Override
    public List<TbInsuranceSettleQueryVo> getSettleList(InsuranceParam insuranceParam) {
        return tbInsuranceSettleMapper.getSettleList(insuranceParam);
    }

    /**
     * 根据赔案id获取所属理赔信息
     * @param caseId
     * @return
     */
    @Override
    public TbInsuranceSettle selectTbInsuranceSettleByCaseId(Long caseId) {


        TbInsuranceSettleCase tbInsuranceSettleCase = tbInsuranceSettleCaseService.selectTbInsuranceSettleCaseById(caseId);
        if (null != tbInsuranceSettleCase)
        {
            return tbInsuranceSettleMapper.selectTbInsuranceSettleById(tbInsuranceSettleCase.getSettleId());
        }
        return null;
    }

    @Override
    public TbInsuranceSettleDetailVo selectTbInsuranceSettleByInsureId(InsuranceQueryParam insuranceQueryParam) {
        return tbInsuranceSettleMapper.selectTbInsuranceSettleByInsureId(insuranceQueryParam);
    }

    /**
     * 累计赔款收入
     * @param insuranceParam
     * @return
     */
    @Override
    public BigDecimal getCompleteAmountTotal(InsuranceParam insuranceParam) {
        return tbInsuranceSettleMapper.getCompleteAmountTotal(insuranceParam);
    }
}
